package zozopo.warehouse;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.background.operator.operations.OperatorTB;
import zozopo.background.operator.operations.OperatorlimitedTB;
import zozopo.user.operations.UserOS;
import zozopo.user.operations.UserTB;
import zozopo.warehouse.operations.AftersaleserviceOS;
import zozopo.warehouse.operations.AftersaleserviceTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class PreModifyAftersaleServiceAction extends ActionSupport implements Action,SessionAware{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final String limitedCode ="WAREHOUSE.AFTERSALESERVICE.MODIFY";
	
	
	//传入参数
	private int id;

	//传出参数
	private AftersaleserviceTB aftersaleservice;
	
	private Map<Object, Object> session;
	
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	
	
	public String execute(){
			
			
			
			String forward = SUCCESS;
			
		
			
			AftersaleserviceOS aftersaleserviceOS = new AftersaleserviceOS();
			try{
				
				aftersaleservice = aftersaleserviceOS.get(id);
				
			}catch (Exception e) 
			{
				forward = ERROR;
				e.printStackTrace();
				
			}finally{
				aftersaleserviceOS.releaseConnection();
			}
			
			return forward;
	}
	
	public void validate() {
		//权限处理
		OperatorTB operator = (OperatorTB)session.get("operatorInfo"); 
	
		if(operator == null){
			addFieldError("errormessage",getText("operator.timeoutornotlogin"));
			return ; 
		} 
		
		//用户权限
		Map<String,OperatorlimitedTB> operatorlimitedMap = (Map<String,OperatorlimitedTB>)session.get("operatorlimitedMap");
		
		if(operatorlimitedMap.get(limitedCode) == null){
			addFieldError("errormessage","用户没有修改售后信息权限.");
			return;
		}
		
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public AftersaleserviceTB getAftersaleservice() {
		return aftersaleservice;
	}


	public void setAftersaleservice(AftersaleserviceTB aftersaleservice) {
		this.aftersaleservice = aftersaleservice;
	}


	public static String getLimitedcode() {
		return limitedCode;
	}
	
}
